<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Adds a circular arc</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="cairocontext.appendpath.html">CairoContext::appendPath</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="cairocontext.arcnegative.html">CairoContext::arcNegative</a></div>
 <div class="up"><a href="class.cairocontext.html">CairoContext</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="cairocontext.arc" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">CairoContext::arc</h1>
  <h1 class="refname">cairo_arc</h1>
  <p class="verinfo">(PECL cairo &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">CairoContext::arc</span> -- <span class="refname">cairo_arc</span> &mdash; <span class="dc-title">Adds a circular arc</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-cairocontext.arc-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格 (method):</p>
   <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>CairoContext::arc</strong></span>
    ( <span class="methodparam"><span class="type">float</span> <code class="parameter">$x</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$y</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$radius</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$angle1</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$angle2</code></span>
    )</div>

  <p class="para rdfs-comment">过程化风格:</p>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>cairo_arc</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.cairocontext.html" class="type CairoContext">CairoContext</a></span> <code class="parameter">$context</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$x</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$y</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$radius</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$angle1</code></span>
   , <span class="methodparam"><span class="type">float</span> <code class="parameter">$angle2</code></span>
   )</div>

  <p class="para rdfs-comment">
   Adds a circular arc of the given radius to the current path.
   The arc is centered at (<em><code class="parameter">x</code></em>, <em><code class="parameter">y</code></em>), begins at
   <em><code class="parameter">angle1</code></em> and proceeds in the direction of increasing angles to end at
   <em><code class="parameter">angle2</code></em>.
   If <em><code class="parameter">angle2</code></em> is less than <em><code class="parameter">angle1</code></em> it will be
   progressively increased by 2*M_PI until it is greater than <em><code class="parameter">angle1</code></em>.
   
   If there is a current point, an initial line segment will be added to the path to connect the
   current point to the beginning of the arc. If this initial line is undesired,
   it can be avoided by calling <span class="methodname"><a href="cairocontext.newsubpath.html" class="methodname">CairoContext::newSubPath()</a></span> or procedural 
   <span class="function"><a href="cairocontext.newsubpath.html" class="function">cairo_new_sub_path()</a></span> before calling <span class="methodname"><strong>CairoContext::arc()</strong></span>
   or <span class="function"><strong>cairo_arc()</strong></span>.

    Angles are measured in radians. An angle of 0.0 is in the direction of the positive X axis
    (in user space). An angle of M_PI/2.0 radians (90 degrees) is in the direction of the positive
    Y axis (in user space). Angles increase in the direction from the positive X axis toward the
    positive Y axis. So with the default transformation matrix, angles increase in a clockwise direction.

    (To convert from degrees to radians, use degrees * (M_PI / 180.).)
    This function gives the arc in the direction of increasing angles; see
    <span class="methodname"><a href="cairocontext.arcnegative.html" class="methodname">CairoContext::arcNegative()</a></span> or <span class="function"><a href="cairocontext.arcnegative.html" class="function">cairo_arc_negative()</a></span>
    to get the arc in the direction of decreasing angles.

    
  </p>
 
 </div>


 <div class="refsect1 parameters" id="refsect1-cairocontext.arc-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">context</code></em></dt>

     <dd>

      <p class="para">
       A valid CairoContext object
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">x</code></em></dt>

     <dd>

      <p class="para">
       x position
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">y</code></em></dt>

     <dd>

      <p class="para">
       y position
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">radius</code></em></dt>

     <dd>

      <p class="para">
       Radius of the arc
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">angle1</code></em></dt>

     <dd>

      <p class="para">
       start angle
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">angle2</code></em></dt>

     <dd>

      <p class="para">
       end angle
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-cairocontext.arc-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-cairocontext.arc-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2783">
    <p><strong>Example #1 面向对象风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$s&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">CairoImageSurface</span><span style="color: #007700">(</span><span style="color: #0000BB">CairoFormat</span><span style="color: #007700">::</span><span style="color: #0000BB">ARGB32</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">CairoContext</span><span style="color: #007700">(</span><span style="color: #0000BB">$s</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setSourceRgb</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">paint</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setLineWidth</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setSourceRgb</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br />for&nbsp;(</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">50</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">-=&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">arc</span><span style="color: #007700">(</span><span style="color: #0000BB">50</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">50</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">M_PI</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stroke</span><span style="color: #007700">();<br />&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fill</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">writeToPng</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/CairoContext__arc.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2784">
    <p><strong>Example #2 过程化风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$s&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cairo_image_surface_create</span><span style="color: #007700">(</span><span style="color: #0000BB">CAIRO_SURFACE_TYPE_IMAGE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cairo_create</span><span style="color: #007700">(</span><span style="color: #0000BB">$s</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cairo_set_source_rgb</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cairo_paint</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cairo_set_source_rgb</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cairo_set_line_width</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br />for&nbsp;(</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">50</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">-=&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">cairo_arc</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">50</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">50</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">M_PI</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">cairo_stroke</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">cairo_fill</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">cairo_surface_write_to_png</span><span style="color: #007700">(</span><span style="color: #0000BB">$s</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/cairo_arc.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-cairocontext.arc-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="cairocontext.arcnegative.html" class="methodname" rel="rdfs-seeAlso">CairoContext::arcNegative()</a> - Adds a negative arc</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="cairocontext.appendpath.html">CairoContext::appendPath</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="cairocontext.arcnegative.html">CairoContext::arcNegative</a></div>
 <div class="up"><a href="class.cairocontext.html">CairoContext</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
